﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Prepare : MonoBehaviour {
    public static Prepare instance;
    [Header("绑定")]
    public _EventManager _EventManager;
    public _TriggerEventManager _TriggerEventManager;

    public Button testStartingButton;
    public Button testGameButton;

    private void Awake() {
        instance = this;
    }

    // Start is called before the first frame update
    void Start() {
        _EventManager.__AttachEvent("LoadingStable", RefreshWindow);
        _EventManager.__AttachEvent("Prepare", OnPrepare);

        testStartingButton.onClick.AddListener(ClickStartingButton);
        testGameButton.onClick.AddListener(ClickGameButton);
        gameObject.SetActive(false);
    }

    private void OnPrepare(object o) {
        //_TriggerEventManager.TriggerEvent("NewGameInit");
    }

    //显示窗口控制
    private void RefreshWindow(object loadingType) {
        switch ((LoadingType)loadingType) {
            case LoadingType.Starting2Prepare:
                gameObject.SetActive(true);
                break;

            case LoadingType.Prepare2Gaming:
                gameObject.SetActive(false);
                break;

            case LoadingType.Prepare2Starting:
                gameObject.SetActive(false);
                break;

        }
    }

    private void ClickStartingButton() {
        _TriggerEventManager.TriggerEvent("Starting");
    }

    private void ClickGameButton() {
        _TriggerEventManager.TriggerEvent("Game");
    }

}
